Skip to content

fix(plugin): keep candidate plugin name when installing from a directory - #608

Open
amdadulbari wants to merge 1 commit into
notaryproject:mainfrom
amdadulbari:fix/plugin-install-candidate-name
Open

amdadulbari wants to merge 1 commit into
notaryproject:mainfrom
amdadulbari:fix/plugin-install-candidate-name

Conversation

@amdadulbari

Copy link
Copy Markdown

Fixes #607

parsePluginFromDir assigned the result of parsePluginName straight to candidatePluginName for every regular file. parsePluginName returns an empty name for a file that does not follow the notation-{plugin-name} format, so any such file visited after the candidate (the walk is in lexical order) reset the candidate name to "".

Installing from a directory like

notation-foo   (not executable)
readme.md

then failed with

failed to get metadata of new plugin: plugin executable file name must be "notation-foo" instead of "notation-foo"

while the same directory installs fine when the extra file sorts before the candidate (LICENSE, libfoo).

The candidate name is now only updated when the file name is a valid plugin executable file name.

Testing

Added a TestManager_Install case with a non-executable notation-foo followed by readme.md. It fails without the change with the error above and passes with it. go test ./... and go vet ./plugin/... pass locally (Linux, Go 1.27).

When a plugin directory contains no executable file but exactly one file
named notation-{plugin-name}, Install sets the executable bit on that
candidate and installs it. parsePluginFromDir stored the result of
parsePluginName directly in candidatePluginName for every regular file,
so any file visited after the candidate whose name does not follow the
notation-{plugin-name} format reset it to an empty string.

As a result, installing from a directory such as

    notation-foo   (not executable)
    readme.md

failed with the misleading error

    failed to get metadata of new plugin: plugin executable file name
    must be "notation-foo" instead of "notation-foo"

while the same directory installs fine if the extra file sorts before
the candidate (e.g. LICENSE or libfoo).

Only update candidatePluginName when the file name is a valid plugin
executable file name.

Signed-off-by: Md. Amdadul Bari Imad <amdadulbari@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin install from a directory fails when a non-plugin file sorts after a non-executable notation-{name} file

1 participant